#include <QString>
#include <iostream>
#include "objectTreeItem.h"
#include "defines/primitive.h"
#include "defines/operation.h"

ObjectTreeItem::ObjectTreeItem(QTreeWidgetItem *_parentItem, Object *_obj) : QTreeWidgetItem(_parentItem), obj(_obj){
    setExpanded(true);
    update();
}

ObjectTreeItem::~ObjectTreeItem(){
}

void ObjectTreeItem::update(){
    QString str = "";

    if(obj->isPrimitive()){
        switch(obj->getType()){
            case CUBOID:{
                str.append(QString::fromUtf8("Cubóide "));
                break;
            }
            case SPHERE:{
                str.append(QString("Esfera "));
                break;
            }
            case CYLINDER:{
                str.append(QString("Cilindro "));
                break;
            }
            case CONE:{
                str.append(QString("Cone "));
                break;
            }
        }
    }else{
        switch(obj->getType()){
            case UNION:
                str.append(QString::fromUtf8("União "));
            break;
            case INTERSECTION:
                str.append(QString::fromUtf8("Interseção "));
            break;
            case DIFFERENCE:
                str.append(QString::fromUtf8("Diferença "));
            break;
        }
    }

    str.append(QString::number(obj->getId()));
    setText(0, str);
}

Object *ObjectTreeItem::getObject(){
    return obj;
}

void ObjectTreeItem::select(bool _b){
    obj->select(_b);
}
